BASE:=$(shell pwd | xargs basename)
CPPFLAGS = -I. -I ../../include
CPPSOURCES=${wildcard *.cpp}
VERION=?-g

EXTENSION=
ifeq ($(VERSION),-g)
EXTENSION=-g
endif


OBJECTS=$(patsubst %.cpp,%$(EXTENSION).o,$(CPPSOURCES))

ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
-include $(SOURCE_DEPENDENCIES)
endif


../../lib/lib$(BASE)$(EXTENSION).a: $(OBJECTS)
	@echo $(OBJECTS)
	@ar rcs $@ $(OBJECTS)
	rm $<

%$(EXTENSION).o: %.cpp
	ag++ $(EXTENSION) -c $(CPPFLAGS) $< -o $@
	cp $@ ../../.objs


echo:
	@echo $(OBJECTS)
	@echo $(CPPSOURCES)s

clean:
	rm -f *.o *.d
